#!/usr/bin/env perl

use v5.14;
use utf8::all;

use Encode;
use HTML::Strip;
use HTML::Entities;

my $accum;
my $strip = HTML::Strip->new(decode_entities => 0);

while(<>) {
    if($_ eq "\0\n") {
        # work around HTML::Strip UTF-8 bug
        say decode_entities(decode('utf-8', $strip->parse(encode('utf-8', $accum))));
        $strip->eof;
        $accum = '';

        print;
    }
    else {
        $accum .= $_;
    }
}

# vim: ft=perl
